package com.huawei.statistics.vo.common;

import java.util.List;

/**
 * Created by XuZhanSi on 2016/11/24 0024.
 * 通用的分页展示
 */
public class PageData<T> {
    private int total;//总记录数
    private List<T> dataList;//数据集
    private int totalPage;//总页数

    private int cur;//当前页数
    private int max;//获取的数量

    public PageData() {
    }

    public PageData(int cur, int max) {
        this.cur = cur;
        this.max = max;
    }

    public int getCur() {
        return cur;
    }

    public void setCur(int cur) {
        this.cur = cur;
    }

    public int getMax() {
        return max;
    }

    public void setMax(int max) {
        this.max = max;
    }

    public PageData(int total, List<T> dataList, int max) {
        this.total = total;
        this.totalPage = (int) (this.total % max == 0 ? this.total / max : Math.floor(this.total / max) + 1);
        this.dataList = dataList;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
        this.totalPage = (int) (this.total % max == 0 ? this.total / max : Math.floor(this.total / max) + 1);
    }

    public List<T> getDataList() {

        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    @Override
    public String toString() {
        return "ResultData{" +
                "total=" + total +
                ", dataList=" + dataList +
                '}';
    }
}
